package com.awspaas.user.apps.publicservice.bean;


public enum ResponseCode {
    SUCCESS_RESPONSE("200","成功"),
    FAIL_PARAMETER("400","错误的参数请求"),
    FAIL_AUTHORITY("401","未授权被拒绝"),
    FAIL_REFUSE("403","访问被拒绝"),
    FAIL_NOT_EXIST("404","流程或环节不存在"),
    FAIL_NOT_ALLOWED("405","请求方法不允许"),
    FAIL_OVERTIME("408","资源请求超时"),
    FAIL_EXCEPTION("500","发生异常"),
    FAIL_TRANSFORM("521","传输转换错误"),
    FAIL_AWS_CONNECTION("590","AWS INSTANCE SERVER连接失败"),
    FAIL_SERVICE_STARTING("760","服务正在启动"),
    FAIL_SERVICE_CLOSE("761","服务正在关闭"),
    FAIL_SERVICE_OFFLINE("762","服务脱机"),
    FAIL_APP_STARTING("770","应用正在启动"),
    FAIL_APP_CLOSE("771","应用正在关闭"),
    FAIL_APP_STOP("774","应用出错暂停"),
    FAIL_LICENSING_RESTRICTIONS("800","许可配额限制");

    private String code;
    private String desc;
    
	ResponseCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    
    /** 根据错误代码获取中文描述 */
    public static String getValue(String code) {
        if(code==null || code.trim().isEmpty()){
            return "";
        }
        String result = "";
        code = code.trim();
        String[] codeArray = code.split(" ");
        for (String codeItem : codeArray){
            for (ResponseCode item : ResponseCode.values()) {
                if (item.getCode().equals(codeItem)) {
                    result = ("".equals(result) ? "" :  result + " ") + item.getDesc();
                }
            }
        }

        return result;
    }

    public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

}
